using System;
using UnityEngine;
using UnityEngine.UI;

namespace VRLauncher
{
    public class UIMainForm : UGuiForm
    {
        [SerializeField]
        private Button optionButton;
        [SerializeField]
        private Button otherButton;
        [SerializeField]
        private Button quitButton;
        [SerializeField]
        private Button updateButton;
        [SerializeField]
        private Text textInfo;

        protected override void OnInit(object userData)
        {
            base.OnInit(userData);

            optionButton.onClick.AddListener(OnSettingButtonClick);
            otherButton.onClick.AddListener(OnotherButtonClick);
            quitButton.onClick.AddListener(OnQuit);
            updateButton.onClick.AddListener(OnUpdate);
            SetTextInfo();
        }
       

        public void OnSettingButtonClick()
        {
            GameManager.UI.OpenUIForm(UIFormId.SettingForm);
            PlayUISound(10001);
        }
        public void OnotherButtonClick()
        {
            PlayUISound(10001);
        }
        public void OnQuit()
        {
            Application.Quit();
#if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
#endif
        }

        private void OnUpdate()
        {
            GameManager.UI.OpenUIForm(UIFormId.UpdateForm);
            PlayUISound(10001);
        }

        public void SetTextInfo()
        {
            textInfo.text = "V 0.11";
        }

    }
}
